第 5 步:这很容易,对吧?但是如果我们希望用户控制星星的数量和颜色会怎样呢?

  • 让我们创建一个名为get_user_input的函数。它将返回用户指定的星星的数量和颜色。
  • ,将Define Function with Docstring def · handle_user_errors()上方 .
  • my_function重命名为get_user_input
  • 最后,将您的文档字符串更改为以下内容: """ Gets the user's input from the console """

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)